//
//  ViewController.m
//  YJPopupView
//
//  Created by Jim1024 on 2016/10/10.
//  Copyright © 2016年 Sunnsoft Co., Ltd. All rights reserved.
//

#import "ViewController.h"
#import "YJPopupView.h"

@interface ViewController ()

@property (nonatomic, strong) UIView *redView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"YJPopupView";
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    NSLog(@"touchesBegan");
    
     _redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
    _redView.backgroundColor = [UIColor blueColor];
    UIButton *dismissBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [dismissBtn setTitle:@"关闭弹窗" forState:UIControlStateNormal];
    [dismissBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    dismissBtn.frame = CGRectMake(0, 0, 100, 44);
    dismissBtn.center = _redView.center;
    dismissBtn.backgroundColor = [UIColor redColor];
    
    [dismissBtn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
    [_redView addSubview:dismissBtn];
    
    [YJPopupView addContentView:_redView];
    [YJPopupView setPopopType:YJPopupViewTypeCenter];
    [YJPopupView show];
}

- (void)dismiss {
    [YJPopupView dismiss];
}

@end
